const config = require(__dirname + '/config.js');
const Cron = require('croner');
const { exec } = require('child_process');


for (let r of config.rules) {
    console.log('starting:', r.title);
    Cron(r.period, () => {
        exec(`${r.program} ${r.task_path}${r.script}`, (error, stdout, stderr) => {
            if (error) {
                console.error(`exec error: ${error}`);
                return;
            }
            console.log(`stdout: ${stdout}`);
            if (stderr) console.error(`stderr: ${stderr}`);
        });
    });
}


